# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Contributor: Justin Berthault <justin.berthault@zaclys.net>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=micro
pkgver=2.0.13
pkgrel=3
# This will need to be updated along with version as it cannot currently be
# obtained from the tarball, and is necessary if the user is to make error
# reports upsteam.
_commithash=68d88b571de6dca9fb8f03e2a3caafa2287c38d4
pkgdesc="A modern and intuitive terminal-based text editor"
url="https://micro-editor.github.io/"
arch="all"
license="MIT"
makedepends="go"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/zyedidia/micro/archive/v$pkgver.tar.gz"
options="!check chmod-clean"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go generate ./runtime
	go build -o micro -ldflags "
		-X github.com/zyedidia/micro/v2/internal/util.Version=$pkgver-$pkgrel
		-X github.com/zyedidia/micro/v2/internal/util.CommitHash=$_commithash
		-X github.com/zyedidia/micro/v2/internal/util.CompileDate=$SOURCE_DATE_EPOCH
		" ./cmd/micro
}

package() {
	install -Dm755 micro -t "$pkgdir"/usr/bin

	install -Dm644 assets/packaging/micro.1 \
		-t "$pkgdir"/usr/share/man/man1/
	install -Dm644 LICENSE* \
		-t "$pkgdir"/usr/share/licenses/$pkgname/

	install -Dm644 assets/packaging/micro.desktop \
		-t "$pkgdir"/usr/share/applications/
	install -Dm644 assets/micro-logo.svg \
		-t "$pkgdir"/usr/share/icons/hicolor/scalable/apps/
}

sha512sums="
b4b1dd3b03c906ee5c0bf9d0b576efea2a527fcdb0fe40338c78515fd5f6a4eb22bd9541567bb5956c4087e749775a1e8c33a73d185f7a6b00ba91e405d6a117  micro-2.0.13.tar.gz
"
